//
//  UserManager.h
//  YoucApp
//
//  Created by Liam on 12-10-16.
//  Copyright 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SingletonDefine.h"
#import "YADelegateUser.h"
#import "YAObjUserInfo.h"

// YARespLoginInfo *loginInfo = [notification object];
#define UMUserLoginDidFinishedNotification				@"UMUserLoginDidFinishedNotification"
#define UMUserLogoutDidFinishedNotification				@"UMUserLogoutDidFinishedNotification"

// YAObjUserInfo *userInfo = [notification object];
#define UMGetUserInfoDidFinishedNotification			@"UMGetUserInfoDidFinishedNotification"

@interface UserManager : NSObject <YADelegateUser> {
	BOOL _isLoginLoading;
	BOOL _isShowingError;
}

OBJC_DEF_SINGLETON(UserManager);

@property (nonatomic, readonly) BOOL isLoginLoading;
@property (nonatomic, readonly) BOOL isUserLogined;
@property (atomic, retain) YAObjUserInfo *userInfo;

- (BOOL)doAutoLogin;
- (BOOL)checkUserLogin;
- (BOOL)doLogin;
- (void)doLogout;

- (void)userRegister:(NSString *)userAccount password:(NSString *)password nickname:(NSString *)nickname;
- (void)userLogin:(NSString *)userAccount password:(NSString *)password;
- (void)updateUserInfo:(YAObjUserInfo *)userInfo;

- (void)fillObjectWithSession:(id)object;

- (void)saveLoginName:(NSString *)loginName;
- (void)savePassword:(NSString *)password;
- (void)saveTempPassword:(NSString *)password;
- (NSString *)getSavedLoginName;
- (NSString *)getSavedPassword;
- (NSString *)getDisplayLoginName;
- (NSString *)getLoginUserId;

@end
